package mysql

import (
	"exam/rpc/model"
	"fmt"
	"gorm.io/driver/mysql"
	"gorm.io/gorm"
)

var DB *gorm.DB

func MysqlInit() {
	var err error
	dsn := "root:root@tcp(127.0.0.1:3306)/zy1?charset=utf8mb4&parseTime=True&loc=Local"
	DB, err = gorm.Open(mysql.Open(dsn), &gorm.Config{})
	if err != nil {
		return
	}
	fmt.Println("mysql连接成功")
	DB.Debug().AutoMigrate(&model.User{})
}
